Change the way domain configuration is handled in xm-test.
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Tue, 13 Dec 2005 16:26:24 +0000 (16:26 +0000)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Tue, 13 Dec 2005 16:26:24 +0000 (16:26 +0000)
This will simplify the way we differentiate between HV and PV domains,
as well as make it easier to run normal tests in either HV or PV mode.

This patch has been modified by Ewan Mellor, to match his recent changes to
remove the nics= configuration option.

Signed-off-by: Dan Smith <danms@us.ibm.com>
Signed-off-by: Dan Stekloff <dsteklof@us.ibm.com>
24 files changed:
tools/xm-test/lib/XmTestLib/XenDomain.py
tools/xm-test/tests/block-create/11_block_attach_shared_dom0.py
tools/xm-test/tests/block-create/12_block_attach_shared_domU.py
tools/xm-test/tests/block-destroy/01_block-destroy_btblock_pos.py
tools/xm-test/tests/block-destroy/05_block-destroy_byname_pos.py
tools/xm-test/tests/block-list/01_block-list_pos.py
tools/xm-test/tests/block-list/03_block-list_anotherbd_pos.py
tools/xm-test/tests/create/01_create_basic_pos.py
tools/xm-test/tests/create/06_create_mem_neg.py
tools/xm-test/tests/create/07_create_mem64_pos.py
tools/xm-test/tests/create/08_create_mem128_pos.py
tools/xm-test/tests/create/09_create_mem256_pos.py
tools/xm-test/tests/create/11_create_concurrent_pos.py
tools/xm-test/tests/create/12_create_concurrent_stress_pos.py
tools/xm-test/tests/create/13_create_multinic_pos.py
tools/xm-test/tests/create/14_create_blockroot_pos.py
tools/xm-test/tests/create/15_create_smallmem_pos.py
tools/xm-test/tests/memset/03_memset_random_pos.py
tools/xm-test/tests/network/02_network_local_ping_pos.py
tools/xm-test/tests/network/05_network_dom0_ping_pos.py
tools/xm-test/tests/network/11_network_domU_ping_pos.py
tools/xm-test/tests/restore/04_restore_withdevices_pos.py
tools/xm-test/tests/sedf/01_sedf_multi_pos.py
tools/xm-test/tests/vcpu-disable/01_vcpu-disable_basic_pos.py

index 05ad6b36dc856a751d64b2e1e2d79b8887a22c64..5838f4693e6e362981549f419411fa22eae92501 100644 (file)
@@ -30,18 +30,140 @@ from config import *
 
 BLOCK_ROOT_DEV = "hda"
 
-def XmTestDomain(name=None, extraOpts=None, config="/dev/null"):
-    if ENABLE_VMX_SUPPORT:
-        return XmTestVmxDomain(name, extraOpts, config)
+def getDeviceModel():
+    """Get the path to the device model based on
+    the architecture reported in uname"""
+    arch = os.uname()[4]
+    if re.search("64", arch):
+        return "/usr/lib64/xen/bin/qemu-dm"
     else:
-        return XmTestPvDomain(name, extraOpts, config)
+        return "/usr/lib/xen/bin/qemu-dm"
 
 def getDefaultKernel():
+    """Get the path to the default DomU kernel"""
     dom0Ver = commands.getoutput("uname -r");
     domUVer = dom0Ver.replace("xen0", "xenU");
     
     return "/boot/vmlinuz-" + domUVer;
 
+def getUniqueName():
+    """Get a uniqueish name for use in a domain"""
+    unixtime = int(time.time())
+    test_name = sys.argv[0]
+    test_name = re.sub("\.test", "", test_name)
+    test_name = re.sub("[\/\.]", "", test_name)
+    name = "%s-%i" % (test_name, unixtime)
+    
+    return name
+
+def getRdPath():
+    rdpath = os.environ.get("RD_PATH")
+    if not rdpath:
+        rdpath = "../../ramdisk"
+    rdpath = os.path.abspath(rdpath)
+
+    return rdpath
+
+ParavirtDefaults = {"memory"       : 64,
+                    "vcpus"        : 1,
+                    "kernel"       : getDefaultKernel(),
+                    "root"         : "/dev/ram0",
+                    "ramdisk"      : getRdPath() + "/initrd.img"
+                    }
+VmxDefaults =      {"memory"       : 64,
+                    "vcpus"        : 1,
+                    "nics"         : 0,
+                    "disk"         : ["file:%s/disk.img,ioemu:%s,w" %
+                                   (getRdPath(), BLOCK_ROOT_DEV)],
+                    "kernel"       : "/usr/lib/xen/boot/vmxloader",
+                    "builder"      : "vmx",
+                    "sdl"          : 0,
+                    "vnc"          : 0,
+                    "vncviewer"    : 0,
+                    "nographic"    : 1,
+                    "serial"       : "pty",
+                    "device_model" : getDeviceModel()
+                    }
+
+if ENABLE_VMX_SUPPORT:
+    configDefaults = VmxDefaults
+else:
+    configDefaults = ParavirtDefaults
+
+class XenConfig:
+    """An object to help create a xen-compliant config file"""
+    def __init__(self):
+        self.defaultOpts = {}
+
+        # These options need to be lists
+        self.defaultOpts["disk"] = []
+        self.defaultOpts["vif"]  = []
+
+        self.opts = self.defaultOpts
+
+    def toString(self):
+        """Convert this config to a string for writing out
+        to a file"""
+        string = "# Xen configuration generated by xm-test\n"
+        for k, v in self.opts.items():
+            if isinstance(v, int):
+                piece = "%s = %i" % (k, v)
+            elif isinstance(v, list) and v:
+                piece = "%s = %s" % (k, v)
+            elif isinstance(v, str) and v:
+                piece = "%s = \"%s\"" % (k, v)
+            else:
+                piece = None
+
+            if piece:
+                string += "%s\n" % piece
+
+        return string
+
+    def write(self, filename):
+        """Write this config out to filename"""
+        output = file(filename, "w")
+        output.write(self.toString())
+        output.close()
+
+    def __str__(self):
+        """When used as a string, we represent ourself by a config
+        filename, which points to a temporary config that we write
+        out ahead of time"""
+        filename = "/tmp/xm-test.conf"
+        self.write(filename)
+        return filename
+
+    def setOpt(self, name, value):
+        """Set an option in the config"""
+        if name in self.opts.keys() and isinstance(self.opts[name], list) and not isinstance(value, list):
+                self.opts[name] = [value]
+        else:
+            self.opts[name] = value
+
+    def appOpt(self, name, value):
+        """Append a value to a list option"""
+        if name in self.opts.keys() and isinstance(self.opts[name], list):
+            self.opts[name].append(value)
+
+    def getOpt(self, name):
+        """Return the value of a config option"""
+        if name in self.opts.keys():
+            return self.opts[name]
+        else:
+            return None
+
+    def setOpts(self, opts):
+        """Batch-set options from a dictionary"""
+        for k, v in opts.items():
+            self.setOpt(k, v)
+
+    def clearOpts(self, name=None):
+        """Clear one or all config options"""
+        if name:
+            self.opts[name] = self.defaultOpts[name]
+        else:
+            self.opts = self.defaultOpts
 
 class DomainError(Exception):
     def __init__(self, msg, extra="", errorcode=0):
@@ -55,62 +177,24 @@ class DomainError(Exception):
     def __str__(self):
         return str(self.msg)
 
-class XenDomain:
-
-    def __init__(self, opts={}, config="/dev/null"):
-        """Create a domain object.  Optionally take a 
-        dictionary of 'xm' options to use"""
-
-        self.domID = None;
-        self.config = config
-
-        if not opts.has_key("name"):
-            raise DomainError("Missing `name' option")
-        if not opts.has_key("memory"):
-            raise DomainError("Missing `memory' option")
-        if not opts.has_key("kernel"):
-            raise DomainError("Missing `kernel' option")
 
-        self.opts = opts
-
-        self.configVals = None
-
-    def __buildCmdLine(self):
-        c = "xm create %s" % self.config
+class XenDomain:
 
-        for k in self.opts.keys():
-            c += " %s=%s" % (k, self.opts[k])
-        
-        return c
+    def __init__(self, name=None, config=None):
+        """Create a domain object.
+        @param config: String filename of config file
+        """
 
-    def getUniqueName(self):
-        #
-        # We avoid multiple duplicate names
-        # here because they stick around in xend
-        # too long
-        #
-        unixtime = int(time.time())
-        test_name = sys.argv[0]
-        test_name = re.sub("\.test", "", test_name)
-        test_name = re.sub("[\/\.]", "", test_name)
-        name = "%s-%i" % (test_name, unixtime)
+        if name:
+            self.name = name
+        else:
+            self.name = getUniqueName()
 
-        return name
+        self.config = config
 
     def start(self):
 
-        if self.configVals:
-            self.__writeConfig("/tmp/xm-test.conf")
-            self.config = "/tmp/xm-test.conf"
-
-        commandLine = self.__buildCmdLine()
-
-        ret, output = traceCommand(commandLine);
-
-        try:
-            self.domID = self.getId()
-        except:
-            self.domID = -1;
+        ret, output = traceCommand("xm create %s" % self.config)
 
         if ret != 0:
             raise DomainError("Failed to create domain",
@@ -118,190 +202,79 @@ class XenDomain:
                               errorcode=ret)
 
     def stop(self):
-        prog = "xm";
-        cmd = " shutdown ";
+        prog = "xm"
+        cmd = " shutdown "
 
-        ret, output = traceCommand(prog + cmd + self.opts["name"]);
+        ret, output = traceCommand(prog + cmd + self.config.getOpt("name"))
 
-        return ret;
+        return ret
 
     def destroy(self):
-        prog = "xm";
-        cmd = " destroy ";
+        prog = "xm"
+        cmd = " destroy "
 
-        ret, output = traceCommand(prog + cmd + self.opts["name"]);
+        ret, output = traceCommand(prog + cmd + self.config.getOpt("name"))
 
-        return ret;
+        return ret
 
     def getName(self):
-        return self.opts["name"];
+        return self.name
 
     def getId(self):
         return domid(self.getName());
 
-    def configSetVar(self, key, value):
-        if not self.configVals:
-            self.configVals = {}
-
-        self.configVals[key] = value
-
-    def configAddDisk(self, pdev, vdev, acc):
-        if not self.configVals:
-            self.configVals = {}
 
-        if not self.configVals.has_key("disk"):
-            self.configVals["disk"] = []
+class XmTestDomain(XenDomain):
 
-        self.configVals["disk"].append("%s,%s,%s" % (pdev,vdev,acc))
+    def __init__(self, name=None, extraConfig=None, baseConfig=configDefaults):
+        """Create a new xm-test domain
+        @param name: The requested domain name
+        @param extraConfig: Additional configuration options
+        @param baseConfig: The initial configuration defaults to use
+        """
+        config = XenConfig()
+        config.setOpts(baseConfig)
+        if extraConfig:
+            config.setOpts(extraConfig)
 
-    def configAddVif(self, type, mac, bridge):
-        if not self.configVals:
-            self.configVals = {}
-
-        if not self.configVals.has_key("vif"):
-            self.configVals["vif"] = []
-
-        if mac:
-            self.configVals["vif"].append("%s,%s,%s" % (type,mac,bridge))
-        else:
-            self.configVals["vif"].append("%s,%s" % (type,bridge))
+        if name:
+            config.setOpt("name", name)
+        elif not config.getOpt("name"):
+            config.setOpt("name", getUniqueName())
 
-    def __writeConfig(self, configFileName):
-
-        conf = file(configFileName, "w")
-
-        for k,v in self.configVals.items():
-            print >>conf, "%s = %s" % (k, v)
-
-        conf.close()
-
-class XmTestVmxDomain(XenDomain):
-
-    def __prepareBlockRoot(self, rdpath):
-        image = os.path.abspath(rdpath + "/disk.img")
-        self.configAddDisk("file:%s" % image, "ioemu:%s" % BLOCK_ROOT_DEV, "w")
-
-    def __prepareVif(self):
-        self.configAddVif("type=ioemu", None, "bridge=xenbr0")
-
-    def __prepareDeviceModel(self):
-        arch = os.uname()[4]
-        if re.search('64', arch):
-            self.configSetVar("device_model", "\"/usr/lib64/xen/bin/qemu-dm\"")
-        else:
-            self.configSetVar("device_model", "\"/usr/lib/xen/bin/qemu-dm\"")
-
-    def __init__(self, name=None, extraOpts=None, config="/dev/null"):
-
-        rdpath = os.environ.get("RD_PATH")
-        if not rdpath:
-            rdpath = "../../ramdisk"
-
-        self.opts = {}
-        self.configVals = {}
-
-        # Defaults
-        self.defaults = {"memory"    : 64,
-                         "vcpus"     : 1,
-                         "kernel"    : "/usr/lib/xen/boot/vmxloader",
-                         "builder"   : "\'vmx\'",
-                         "name"      : name or self.getUniqueName()
-                         }
-
-        self.domID = None;
-        self.config = config;
-
-        self.__prepareBlockRoot(rdpath)
-       #self.__prepareVif()
-        self.__prepareDeviceModel()
-        #self.configSetVar("boot","\'c\'")
-        self.configSetVar("sdl","0")
-        self.configSetVar("vnc","0")
-        self.configSetVar("vncviewer","0")
-        self.configSetVar("nographic","1")
-        self.configSetVar("serial","\'pty\'")
-
-        # Copy over defaults
-        for key in self.defaults.keys():
-            self.opts[key] = self.defaults[key]
-
-        # Merge in extra options
-        if extraOpts:
-            for key in extraOpts.keys():
-                self.opts[key] = extraOpts[key]
+        XenDomain.__init__(self, config.getOpt("name"), config=config)
 
     def start(self):
-        """We know how about how long everyone will need to wait
-        for our disk image to come up, so we do it here as a convenience"""
-
-#        for i in range(0,5):
-#            status, output = traceCommand("xm list")
-
         XenDomain.start(self)
-        waitForBoot()
+        if ENABLE_VMX_SUPPORT:
+            waitForBoot()
 
     def startNow(self):
         XenDomain.start(self)
 
-    def getMem(self):
-        return int(self.opts["memory"])
-
     def minSafeMem(self):
         return 16
 
-class XmTestPvDomain(XenDomain):
-
-    def __init__(self, name=None, extraOpts=None, config="/dev/null"):
-
-        rdpath = os.environ.get("RD_PATH")
-        if not rdpath:
-            rdpath = "../../ramdisk"
-
-        self.opts = {}
-        self.configVals = None
-
-        # Defaults
-        self.defaults = {"memory"  : 64,
-                         "vcpus"   : 1,
-                         "kernel"  : getDefaultKernel(),
-                         "root"    : "/dev/ram0",
-                         "name"    : name or self.getUniqueName(),
-                         "ramdisk" : rdpath + "/initrd.img"
-                         }
-
-        self.domID = None;
-        self.config = config;
-
-        # Copy over defaults
-        for key in self.defaults.keys():
-            self.opts[key] = self.defaults[key]
-
-        # Merge in extra options
-        if extraOpts:
-            for key in extraOpts.keys():
-                self.opts[key] = extraOpts[key]
-
-    def start(self):
-        """We know how about how long everyone will need to wait
-        for our ramdisk to come up, so we do it here as a convenience"""
+if __name__ == "__main__":
 
-#        for i in range(0,5):
-#            status, output = traceCommand("xm list")
+    c = XenConfig()
 
-        XenDomain.start(self)
-#        waitForBoot()
+    c.setOpt("foo", "bar")
+    c.setOpt("foob", 1)
+    opts = {"opt1" : 19,
+            "opt2" : "blah"}
+    c.setOpts(opts)
 
-    def startNow(self):
-        XenDomain.start(self)
+    c.setOpt("disk", "phy:/dev/ram0,hda1,w")
+    c.appOpt("disk", "phy:/dev/ram1,hdb1,w")
 
-    def getMem(self):
-        return int(self.opts["memory"])
+    print str(c)
 
-    def minSafeMem(self):
-        return 16
+    
 
-if __name__ == "__main__":
+#    c.write("/tmp/foo.conf")
 
-    d = XmTestDomain();
+#    d = XmTestDomain();
+#
+#    d.start();
 
-    d.start();
index 01b3a794d0953e849e2f96997d05664c19415fe9..4f897c3ead6159b0d41ce8043c818f300cebe49c 100644 (file)
@@ -21,8 +21,9 @@ if s != 0:
 
 # Now try to start a DomU with write access to /dev/ram0
 
-domain = XmTestDomain();
-domain.configAddDisk("phy:/dev/ram0", "hda1", "w")
+config = {"disk":"phy:/dev/ram0,hda1,w"}
+
+domain = XmTestDomain(extraConfig=config);
 
 try:
     domain.start()
index 6fba0b1f3d31e1c7287a6d70bb596dc6c566979e..c93077fb4ecf5e661e4d2ab3995f91d6dc0420aa 100644 (file)
@@ -5,11 +5,11 @@
 
 from XmTestLib import *
 
-dom1 = XmTestDomain()
-dom2 = XmTestDomain(dom1.getName() + "-2")
+config = {"disk":"phy:/dev/ram0,hda1,w"}
 
-dom1.configAddDisk("phy:/dev/ram0", "hda1", "w")
-dom2.configAddDisk("phy:/dev/ram0", "hda1", "w")
+dom1 = XmTestDomain(extraConfig=config)
+dom2 = XmTestDomain(dom1.getName() + "-2",
+                    extraConfig=config)
 
 try:
     dom1.start()
index 42d6ba3eaad1773568ab2e181ef513f5b7f3e999..aa456cbdf2c46f7aee3194286876667a975cf691 100644 (file)
@@ -5,9 +5,8 @@
 
 from XmTestLib import *
 
-domain = XmTestDomain()
-
-domain.configAddDisk("phy:/dev/ram0", "hda1", "w")
+config = {"disk":"phy:/dev/ram0,hda1,w"}
+domain = XmTestDomain(extraConfig=config)
 
 try:
     domain.start()
index 8c95fd3b37ff1eb64ac5369ac798c1e0f4fd2622..78e84af1e74b18d1e1816ae20e62e7bf02b0146e 100644 (file)
@@ -5,9 +5,8 @@
 
 from XmTestLib import *
 
-domain = XmTestDomain()
-
-domain.configAddDisk("phy:/dev/ram0", "hda1", "w")
+config = {"disk":"phy:/dev/ram0,hda1,w"}
+domain = XmTestDomain(extraConfig=config)
 
 try:
     domain.start()
index ec297191404be562afeed0aa97ae33888fb21add..dbe7415547efed05b8ea1d820f337219fdbd4146 100644 (file)
@@ -8,9 +8,8 @@
 
 from XmTestLib import *
 
-domain = XmTestDomain()
-
-domain.configAddDisk("phy:/dev/ram0", "hda1", "w")
+config = {"disk":"phy:/dev/ram0,hda1,w"}
+domain = XmTestDomain(extraConfig=config)
 
 try:
     domain.start()
index b7f10e9dc21885165b751e9dc73d5d09ff66312d..442dd901133d2c349165432e1a3f0878cf5a5208 100644 (file)
@@ -8,9 +8,8 @@
 
 from XmTestLib import *
 
-domain = XmTestDomain()
-
-domain.configAddDisk("phy:/dev/ram0", "hda1", "w")
+config = {"disk":"phy:/dev/ram0,hda1,w"}
+domain = XmTestDomain(extraConfig=config)
 
 try:
     domain.start()
index 4ce79f2505b2088fb4a92b4e73d24080e80f31f8..7a45df2de4fe370cedc75972f1666d330f8173a5 100644 (file)
@@ -12,9 +12,9 @@ from XmTestLib import *
 # Create a domain (default XmTestDomain, with our ramdisk)
 domain = XmTestDomain()
 
-if int(getInfo("free_memory")) < domain.getMem():
+if int(getInfo("free_memory")) < domain.config.getOpt("memory"):
     SKIP("This test needs %i MB of free memory (%i MB avail)" %
-         (domain.getMem(), int(getInfo("free_memory"))))
+         (domain.config.getOpt("memory"), int(getInfo("free_memory"))))
 
 # Start it
 try:
index 187495caa0d0aa15a93d018334764466909c6c3d..6f7193636bb1046727de3dd302c45296471e67d0 100644 (file)
@@ -19,15 +19,8 @@ if not rdpath:
        rdpath = "../ramdisk"
 
 # Test 1: create a domain with mem=0
-opts1 =  {
-            "name"    : "default",
-            "memory"  : 0,
-            "kernel"  : getDefaultKernel(),
-            "root"    : "/dev/ram0",
-            "ramdisk" : rdpath + "/initrd.img",
-            }
-
-domain1=XenDomain(opts1)
+config1 = {"memory": 0}
+domain1=XmTestDomain(extraConfig=config1)
 
 try:
     domain1.start()
@@ -43,17 +36,10 @@ if eyecatcher1 != "Fail":
 # Test 2: create a domain with mem>sys_mem
 
 mem = int(getInfo("total_memory"))
-extreme_mem = str(mem + 100)
-
-opts2=  {
-            "name"    : "default",
-            "memory"  : extreme_mem,
-            "kernel"  : getDefaultKernel(),
-            "root"    : "/dev/ram0",
-            "ramdisk" : rdpath + "/initrd.img",
-            }
+extreme_mem = mem + 100
 
-domain2=XenDomain(opts2)
+config2 = {"memory": extreme_mem}
+domain2=XmTestDomain(extraConfig=config2)
 
 try:
     domain2.start()
index 387291d87097041223165f943e9d4ce8e13d8d69..d801b8a8b08365241220f8656f9c1f338b4ea90c 100644 (file)
@@ -23,15 +23,8 @@ if mem < 64:
        SKIP("This test needs 64 MB of free memory (%i MB avail)" % mem)
 
 #create a domain with mem=64
-opts =  {
-            "name"    : "MEM64",
-            "memory"  : 64,
-            "kernel"  : getDefaultKernel(),
-            "root"    : "/dev/ram0",
-            "ramdisk" : rdpath + "/initrd.img",
-            }
-
-domain_mem64=XenDomain(opts)
+config = {"memory": 64}
+domain_mem64=XmTestDomain(extraConfig=config)
 
 #start it
 try:
index 643073ea171a8a5969e5f70434de451aa510f1e8..a830c7dc8e708ba4e7342964ade1f50ef008794b 100644 (file)
@@ -23,15 +23,8 @@ if mem < 128:
         SKIP("This test needs 128 MB of free memory (%i MB avail)" % mem)
 
 #create a domain with mem=128
-opts =  {
-            "name"    : "MEM128",
-            "memory"  : 128,
-            "kernel"  : getDefaultKernel(),
-            "root"    : "/dev/ram0",
-            "ramdisk" : rdpath + "/initrd.img",
-            }
-
-domain_mem128=XenDomain(opts)
+config={"memory": 128}
+domain_mem128=XmTestDomain(extraConfig=config)
 
 #start it
 try:
index afe13926a9c2bfc4e174148f9bee33862d95f087..07d73d8127c8ef6469022ff947206714e30c05dc 100644 (file)
@@ -23,15 +23,8 @@ if mem < 256:
         SKIP("This test needs 256 MB of free memory (%i MB avail)" % mem)
 
 #create a domain with mem=256
-opts =  {
-            "name"    : "MEM256",
-            "memory"  : 256,
-            "kernel"  : getDefaultKernel(),
-            "root"    : "/dev/ram0",
-            "ramdisk" : rdpath + "/initrd.img",
-            }
-
-domain_mem256=XenDomain(opts)
+config = {"memory": 256}
+domain_mem256=XmTestDomain(extraConfig=config)
 
 #start it
 try:
index 5dd473d0dc1358e56c8a8415068c939541902812..d850642e45700587d15535c19af3deaa6a61efa7 100644 (file)
@@ -34,7 +34,7 @@ if verbose:
 
 for d in range(0, NUM_DOMS):
     dom = XmTestDomain(name="11_create_%i" % d,
-                       extraOpts={"memory":str(MEM_PER_DOM)})
+                       extraConfig={"memory":MEM_PER_DOM})
 
     try:
         dom.start()
index e4e925d742efc8727e65d1a544a066c034c698bc..8bffb1b2c6a5559538889c9f6647e7666a30fae3 100644 (file)
@@ -14,7 +14,7 @@ DUR=60
 domains = []
 
 for i in range(0,DOMS):
-    dom = XmTestDomain(extraOpts={"memory" : str(MEM)})
+    dom = XmTestDomain(extraConfig={"memory" : MEM})
 
     try:
         dom.start()
index 0c5c65946981d8dc9e0d2f618580b9f2699f8dbf..eda2e2f8f78b036ad7055aa66f1a43f2dc4d726a 100644 (file)
@@ -6,8 +6,8 @@
 from XmTestLib import *
 
 for i in range(0,10):
-    domain = XmTestDomain()
-    domain.configSetVar('vif', str(['' for _ in range(0, i)]))
+    config = {"vif": ['' for _ in range(0, i)]}
+    domain = XmTestDomain(extraConfig=config)
 
     try:
         domain.start()
index 5f583f2a9fe52580b1e946c9bc7d7c82798d4247..c80a92ca8c910aef4cf00b20160255e92fc53e6c 100644 (file)
@@ -6,10 +6,9 @@
 from XmTestLib import *
 
 import os
+import time
 
-CONF_FILE = "/tmp/14_create_blockroot_pos.conf"
-
-rdpath = os.path.abspath(os.environ.get("RD_PATH"))
+rdpath = getRdPath()
 
 # status, output = traceCommand("losetup -f %s" % rdpath)
 # if status != 0:
@@ -17,22 +16,26 @@ rdpath = os.path.abspath(os.environ.get("RD_PATH"))
 # 
 # if verbose:
 #     print "Using %s" % output
-opts = {"memory" : "64",
-        "root"   : "/dev/hda1",
-        "name"   : "14_create_blockroot",
-        "kernel" : getDefaultKernel() }
-
-domain = XenDomain(opts=opts)
 
-domain.configAddDisk("file:%s/initrd.img" % rdpath, "hda1", "w")
+if ENABLE_VMX_SUPPORT:
+    domain = XmTestDomain(name="14_create_blockroot")
+else:
+    config = {"memory" : "64",
+              "root"   : "/dev/hda1",
+              "name"   : "14_create_blockroot",
+              "kernel" : getDefaultKernel(),
+              "disk"   : "file:%s/initrd.img,hda1,w" % rdpath
+              }
+    domConfig = XenConfig()
+    domConfig.setOpts(config)
+    domain = XenDomain(name=domConfig.getOpt("name"), config=domConfig)
 
 try:
     domain.start()
 except DomainError, e:
       FAIL(str(e))
 
-waitForBoot()
+#waitForBoot()
 
 try:
     console = XmConsole(domain.getName(), historySaveCmds=True)
index b1ec678180d29673f71e5ec138f54e8d1b100425..ed8c24d4ef15c2d66fb4e280c66c308ca8dcc35a 100644 (file)
@@ -7,8 +7,8 @@ from XmTestLib import *
 
 MEM = 16
 
-domain = XmTestDomain(extraOpts={"memory":"%i" % MEM,
-                                 "extra" :"mem=%iM" % MEM})
+domain = XmTestDomain(extraConfig={"memory": MEM,
+                                   "extra" :"mem=%iM" % MEM})
 
 try:
     domain.start()
index 94cf8f973008821ea4f3a3dbaed5afe673c7776a..1f5c0337105b88c6617226145362dbec88ea9b5f 100644 (file)
@@ -20,8 +20,8 @@ except DomainError, e:
     FAIL(str(e))
 
 times = random.randint(10,50)
-origmem = domain.getMem()
-currmem = domain.getMem()
+origmem = domain.config.getOpt("memory")
+currmem = domain.config.getOpt("memory")
 
 try:
     console = XmConsole(domain.getName())
index 510711ae23dc33ab298b28ebc5336a67b2c54c40..fc1dd9abe165caa366cb558b3a2586f74ab74344 100644 (file)
@@ -28,9 +28,9 @@ ip   = Net.ip("dom1", "eth0")
 mask = Net.mask("dom1", "eth0")
 
 # Fire up a guest domain w/1 nic
-domain = XmTestDomain()
+config = {"vif" : ['ip=%s' % ip]}
+domain = XmTestDomain(extraConfig=config)
 try:
-    domain.configSetVar('vif', " [ 'ip=" + ip + "' ]")
     domain.start()
 except DomainError, e:
     if verbose:
index 84e6be058a0267cdb03b4f7607f55638616e82ba..0d218ca0bc701c3934fc99d581ed0cebffb88b33 100644 (file)
@@ -31,9 +31,9 @@ except NetworkError, e:
         FAIL(str(e))
 
 # Fire up a guest domain w/1 nic
-domain = XmTestDomain()
+config = {"vif"  : ["ip=%s" % ip]}
+domain = XmTestDomain(extraConfig=config)
 try:
-    domain.configSetVar('vif', " [ 'ip=" + ip + "' ]")
     domain.start()
 except DomainError, e:
     if verbose:
index 5ac80215627fbee60e1dbe5bab62b32984febfc6..5630ff173825e06d987ad8104405763a1628a7d5 100644 (file)
 pingsizes = [ 1, 48, 64, 512, 1440, 1500, 1505, 4096, 4192, 
               32767, 65507 ]
 
-
-
 from XmTestLib import *
 
-
 def netDomain(ip):
-    dom = XmTestDomain()
+    config = {"vif"  : ["ip=%s" % ip]}
+    domain = XmTestDomain(extraConfig=config)
     try:
-        dom.configSetVar('vif', " [ 'ip=" + ip + "' ]")
         dom.start()
     except DomainError, e:
         if verbose:
index af290f4b8b9329f1f0395a12b9bf9ffaf9fe40d4..61e0b3ed81d4576c28281895af2813abbd15fb6d 100644 (file)
@@ -7,12 +7,9 @@ from XmTestLib import *
 
 import re
 
-domain = XmTestDomain()
-
-domain.configSetVar('vif', "[ '', '' ]")
-
-domain.configAddDisk("phy:/dev/ram0", "hda1", "w")
-domain.configAddDisk("phy:/dev/ram1", "hdb2", "w")
+config = {"disk": ["phy:/dev/ram0,hda1,w", "phy:/dev/ram1,hdb2,w"],
+          "vif":  ['', '']}
+domain = XmTestDomain(extraConfig=config)
 
 s, o = traceCommand("mke2fs -q /dev/ram0")
 if s != 0:
index b44fb46542eee48750617c49100c6062dd862c93..0ec057ded5a429da912cd2ea141660b10deb6cef 100644 (file)
@@ -7,7 +7,7 @@ from XmTestLib import *
 
 sedf_opts = "20000000 5000000 0 0 0"
 
-domain = XmTestDomain(extraOpts = {"sched":"sedf"})
+domain = XmTestDomain(extraConfig = {"sched":"sedf"})
 
 try:
     domain.start()
index cabf8dfed71f849f48c957d46a7ff15727cd9480..4c15735bab69af73b02c51e08a8099f9844b1699 100644 (file)
@@ -39,7 +39,7 @@ if smpConcurrencyLevel() <= 1:
     SKIP("Host not capable of running test")
 
 # Start a XmTestDomain with 2 VCPUs
-domain = XmTestDomain(extraOpts = {"vcpus":"2"})
+domain = XmTestDomain(extraConfig={"vcpus":2})
 
 try:
     domain.start()